//package com.xxjqr.rbac.auth;
//
//import com.alibaba.fastjson.JSON;
//import com.xxjqr.rbac.enums.CodeMsgEnum;
//import com.xxjqr.rbac.response.Response;
//import org.springframework.security.access.AccessDeniedException;
//import org.springframework.security.web.access.AccessDeniedHandler;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
///**
// * 当没有权限时返回自定义JSON
// * @author 丁昌江
// * @Description
// * @createTime 2021年01月15日 20:45:00
// */
//@Component
//public class RestAccessDeniedHandler implements AccessDeniedHandler {
//    @Override
//    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException {
//        Response<Void> fail = Response.fail(CodeMsgEnum.AUTH_FAIL.getCode().toString(), CodeMsgEnum.AUTH_FAIL.getMsg());
//        response.setCharacterEncoding("UTF-8");
//        response.setContentType("application/json");
//        response.getWriter().println(JSON.toJSON(fail));
//        response.getWriter().flush();
//    }
//}
